from ctypes import *
import time

dht11 = CDLL('./dht11.so')
dht11.dht11_init()

dht_exec = dht11.read_dht
dht_exec.restype = c_int
dht_exec.argtypes = [c_int,POINTER(c_int*5)]

data = (c_int*5)()
ptr = pointer(data)
pin = 12

try:
    while True:
        res = dht_exec(pin,ptr)
        if res == 1:
            print("湿度%d.%d\n温度%d.%d\n"%(data[0],data[1],data[2],data[3]))
        
        time.sleep(1)
except KeyboardInterrupt:
    pass